<template>
    <div class="container">
      <!-- 查询个人以往病例的表格 -->
      <div class="table-container">
        <h2>个人以往病例</h2>
        <table class="table">
          <thead>
            <tr>
              <th>诊断时间</th>
              <th>患病信息</th>
              <th>患病拿药</th>
              <th>拿药量</th>
              <th>是否住院</th>
              <th>住院开始时间</th>
              <th>住院结束时间</th>
            </tr>
          </thead>
          <tbody>
            <!-- 这里根据实际数据进行循环渲染 -->
            <tr v-for="(record, index) in this.infoList" :key="index">
              <td>{{ record.dischargeDate }}</td>
              <td>{{ record.diagnosisResult }}</td>
              <td>{{ record.medicationName }}</td>
              <td>{{ record.dosage }}</td>
              <td>{{ record.hospitalized }}</td>
              <td>{{ record.admissionDate }}</td>
              <td>{{ record.dischargeDate }}</td>
            </tr>
          </tbody>
        </table>
      </div>
  
      <!-- 标签展示 -->
      
    </div>
  </template>
  
  
<script>
import * as echarts from "echarts";
import { listInfo, getInfo, delInfo, addInfo, updateInfo , historyInfo } from "@/api/patient_illness_info/info";

export default {
    computed: {
      pw() {
        return this.$route.params.pw;
      }
    },
    name: 'new',
    data() {
      return {
        infoList: [], // 这里可以从后端获取用户的病例记录数据
      };
    },
    
    mounted() {
      this.getTable(this.pw)//获取用户数据


      
    },
    methods: {
      getTable(pw) {
          listInfo({
            pageNum: 1,
            pageSize: 10,
            patientName: null,
            patientIdCard: pw,
            diagnosisDate: null,
            diagnosisResult: null,
            medicationId: null,
            medicationName: null,
            dosage: null,
            hospitalized: null,
            admissionDate: null,
            dischargeDate: null,
            doctorName: null
          }).then(response => {
            console.log(response)
            response.rows.forEach(item => {
              if (item.hospitalized === 1){
                item.hospitalized = '是'
              }else {
                item.hospitalized = '否'
              }
            })
            this.infoList = response.rows;
        });
      }
    }
  };
  
  </script>

 <style scoped>
 .container {
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   margin: 20px;
 }
 
 .table-container {
   width: 100%;
   height: 500px;
   margin-bottom: 50px;
 }
 
 .table {
   width: 100%;
   border-collapse: collapse;
 }
 
 .table th, .table td {
   border: 1px solid #ccc;
   padding: 8px;
   text-align: center;
 }
 
 .tags-container {
   display: flex;
   justify-content: space-around;
   width: 100%;
 }

 </style>
 
  
  
  
  